"""
# -*-coding:utf-8-*-
from codecs import EncodedFile
import re,sys
import requests
from requests.exceptions import ConnectTimeout,ConnectionError,ReadTimeout,SSLError,MissingSchema,ChunkedEncodingError
import logging

# 日志模块
# logger = logging.getLogger("AppName")
# console_handler = logging.StreamHandler(sys.stdout)
# logger.addHandler(console_handler)
# sys.stdout.reconfigure(encoding='utf-8')


def get_logger(log_file):
    
    # 进行日志操作，有专门的日志模块：logging
    # :param log_file:
    # :return:
    
    logger = logging.getLogger(log_file)
    # 设置日志等级
    logger.setLevel(logging.DEBUG)
    file_handler = logging.FileHandler(log_file, encoding='utf8')
    file_handler.setLevel(logging.DEBUG)
    console_handler = logging.StreamHandler()
    console_handler.setLevel(logging.INFO)
    formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
    console_handler.setFormatter(formatter)
    file_handler.setFormatter(formatter)
    logger.addHandler(console_handler)
    logger.addHandler(file_handler)
    return logger
    
logger=get_logger('html.log')
urlhash = "https://weibomiaopai.com/"
# urlhash = "http://www.baidu.com"
try:
    print(requests.get(urlhash).encoding)
    html = requests.get(urlhash).content.decode(encoding='utf8')
    # logging.basicConfig(level=logging.NOTSET,
    #                     filename='html.log',
    #                     filemode='w',
    #                     format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s',
    #                     datefmt='%a, %d %b %Y %H:%M:%S'
    #                     )
    logger.info(html) 
    # print(html)
except SSLError:
    logger.info(u"网络不稳定 正在重试")
    html = requests.get(urlhash).text

reg = re.compile(r'hash=(.*?)"', re.S)
# result = reg.findall(html)
# print(result)
"""

# import numpy as np
# a=np.array([[1,2,4],[4,5,8],[4,9,2]])
# # b=np.ones(3)
# b=np.array(["1"]*3)
# a=np.insert(a, 0, values=b, axis=1) #沿Y轴插入到0列
# print(a)
# # print(["1"]*10)
# print(np.array([["1"],[1]]))
# import pandas as pd
# df=pd.DataFrame()


# import pymysql
# db = pymysql.connect(
#         host='localhost',
#         db='stock',
#         user='root',
#         passwd='kirin',
#         charset='utf8',
#         use_unicode=True)
# cursor = db.cursor()
# cursor.execute("DROP TABLE IF EXISTS f10")
# cursor.execute("CREATE TABLE f10 (序号 int PRIMARY KEY AUTO_INCREMENT,股票代码 TEXT,十大流通股东 TEXT,持有比例 TEXT,本期持有股_万股 TEXT,持股变动数_万股 TEXT)")
# cursor.execute("INSERT INTO f10 (股票代码,十大流通股东,持有比例,本期持有股_万股,持股变动数_万股) VALUES (%s,%s,%s,%s,%s)",("1","2","3","4","5"))
# # cursor.execute("DESCRIBE f10")

# cursor.execute("SELECT * FROM f10")
# for x in cursor:
#     print(x)
import os 
# print(os.getcwd())
# import pandas as pd
# df=pd.DataFrame([1,2])
# print(df)

# def send_to_email(subject_str,filepath_str): #filepath_str:'C:\1.txt'
#     import yagmail

#     # 登录你的邮箱
#     yag = yagmail.SMTP(user = 'jamal121@163.com', password = 'kirin107105', host = 'smtp.163.com')
#     # 发送邮件
#     yag.send(to = ['jamal121@163.com'], subject = subject_str, contents = ['内容',filepath_str])

# path=os.getcwd()
# send_to_email('xi_chou.csv',path+'/xi_chou.csv')

# def xi_chou_check(file_name,code):
#     output_File = open(file_name,'a+') #a+: 附加读写方式打开
#     output_File.write(str(code).zfill(6)+'\n')
#     output_File.flush()#每次写入都保存一次，防止中断全部丢失
#     print(str(code).zfill(6))
#     return "%s complete"%code

# def multi_thread_xi_chou_check(file_name,code_list):
#     """
#     使用线程池，由系统自动分配线程数量，并打印线程目标函数的返回结果
#     """  
#     #在append之前先删除原数据表
#     import concurrent.futures
#     with concurrent.futures.ThreadPoolExecutor() as executor:     
#         # results=executor.map(f10_into_df,code_index_list)
#         results=[ executor.submit(xi_chou_check,file_name,i) for i in code_list]
#         # for result in results:#<Future at 0x1669cf023a0 state=pending>
#         #     print(result)
#         for f in concurrent.futures.as_completed(results):
#             print(f.result())  

# import numpy as np

# file_name="xi_chou_1.csv"
# code_list=np.asarray(range(23))

# multi_thread_xi_chou_check(file_name,code_list)

# for i in range(5):
#     output_File = open("1.csv",'a+') #a+: 附加读写方式打开
#     output_File.write('{},{}\n'.format('111','222'))
#     output_File.flush()#每次写入都保存一次，防止中断全部丢失

# import time
# Today=time.strftime("%Y-%m-%d-%H-%M-%S")
# file_name="{}.csv".format("xi_chou_"+time.strftime("%Y%m%d%H%M%S"))
# print(file_name)
# print(Today)

# import datetime
# import time
# from  chinese_calendar  import is_holiday

# def n_days_before(st_day,n):
#     """
#     st_day:开始日期
#     :type st_day: datetime.date | datetime.datetime
#     """
#     while(n>0):
#         if not is_holiday(st_day):
#             n=n-1
#         st_day=st_day-datetime.timedelta(1)
#     return st_day
"""
import tushare as ts
pro = ts.pro_api()
end_date_str=time.strftime("%Y%m%d")
print(end_date_str)
end_datetime = datetime.datetime.strptime(end_date_str, '%Y%m%d') 
start_datetime=n_days_before(end_datetime,5)
start_date_str=start_datetime.strftime("%Y%m%d")
df = pro.daily(ts_code='{}.SZ'.format(str(3039).zfill(6)), start_date=start_date_str, end_date=end_date_str)
df.set_index('trade_date',inplace=True)
df.sort_index(inplace=True) 
df.rename(columns={'vol': 'volume'},inplace=True)  
df_new=df[["open","high","low","close","volume"]]
close=df_new["close"].to_list()  
print(df_new)
print(close)
low=df_new["low"].to_list()
"""


# from ylTDX import * #from ylTDX import all def function
# print(ADDS([1,2,3],[4,25,4]))
a=[True, False, True]
print([i>0 for i in a])
print(list(range(2,2)))